package org.ladybug.service.auth;

import org.ladybug.dao.persistence.Utente;
import org.springframework.security.GrantedAuthority;
import org.springframework.security.userdetails.UserDetails;

public class LadyBugUserDetails implements UserDetails {
	private Utente utente = null;
	
	public LadyBugUserDetails(Utente utente) {
		this.utente=utente;
	}

	public GrantedAuthority[] getAuthorities() {
		return new GrantedAuthority[]{new GrantedAuthority(){

			public String getAuthority() {
				return "MY_ROLE";
			}

			public int compareTo(Object o) {
				return 0;
			}
			
		}};
	}

	public String getPassword() {
		String password = utente.getPassword();
		return password;
	}

	public String getUsername() {
		// TODO Auto-generated method stub
		return utente.getNickname();
	}

	public boolean isAccountNonExpired() {
		return true;
	}

	public boolean isAccountNonLocked() {
		return true;
	}

	public boolean isCredentialsNonExpired() {
		return true;
	}

	public boolean isEnabled() {
		return true;
	}

	
	//--------------------------------------- get e set properties
	public Utente getUtente() {
		return utente;
	}

	public void setUtente(Utente utente) {
		this.utente = utente;
	}

}
